import Vue, { VueConstructor, PluginObject } from 'vue';
import loglevel from 'loglevel';
// 'trace''debug''info''warn''error''silent'
loglevel.setLevel('info');

const Plugin: PluginObject<any> = {
  install: (v: VueConstructor) => {
    v.$log = loglevel;
  },
};
Plugin.install = (v: VueConstructor) => {
  v.$log = loglevel;
  window.log = loglevel;
  Object.defineProperties(v.prototype, {
    $log: {
      get() {
        return loglevel;
      },
    },
  });
};

Vue.use(Plugin);

export default Plugin;
